package com.yupi.springbootinit.judge.codesanbox.model;

import com.yupi.springbootinit.judge.codesanbox.CodeSanBox;
import com.yupi.springbootinit.judge.codesanbox.model.impl.ExampleCodeSanBox;
import com.yupi.springbootinit.judge.codesanbox.model.impl.RemoteCodeSanBox;
import com.yupi.springbootinit.judge.codesanbox.model.impl.ThridPartyCodeSanBox;

/**
 * 代码沙箱创建工厂 根据字符串参数创建代码沙箱实例
 */
public class CodeSanBoxFactory {

    /**
     * 创建代码沙箱实例
     *
     * @param type
     * @return
     */
    public static CodeSanBox newInstance(String type) {
        if (type.equals(CodeBoxTypeEnum.EXAMPLE.getValue())) {
            return new ExampleCodeSanBox();
        }
        if (type.equals(CodeBoxTypeEnum.REMOTE.getValue())) {
            return new RemoteCodeSanBox();
        }
        if (type.equals(CodeBoxTypeEnum.THIRDPARTY.getValue())) {
            return new ThridPartyCodeSanBox();
        }
        return new ExampleCodeSanBox();

    }

}
